Clarify argument/result ownership/validity for PyModule_* functions#141159
Clarify argument/result ownership/validity for PyModule_* functions#141159encukou merged 2 commits intopython:mainfrom
Conversation
| The *functions* array must be statically allocated (or otherwise guaranteed | ||
| to outlive the module object). |
There was a problem hiding this comment.
I think it's a little bit confusing to say something must be true, and then immediately contradict it. How about we say something like this?
The *functions* array must outlive the module object. A common way to do
this is to statically allocate it.
| The *functions* array must be statically allocated (or otherwise guaranteed | ||
| to outlive the module object). |
There was a problem hiding this comment.
I don't think there is a practical alternative unless you're doing something really special, so I would like keep this footnote-ish -- but part of the same sentence to avoid wording like “as a special exception”.
There was a problem hiding this comment.
Ok, I don't wholly agree, but I won't bother arguing about it.
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
|
Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…ythonGH-141159) (cherry picked from commit ffd6473) Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
|
GH-141190 is a backport of this pull request to the 3.14 branch. |
|
Sorry, @encukou, I could not cleanly backport this to |
…tions (pythonGH-141159) (cherry picked from commit ffd6473) Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
|
GH-141191 is a backport of this pull request to the 3.13 branch. |
|
Thanks! Eventually we'll remove the requirement anyway :) |
…ythonGH-141159) Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
When working on PEP-793 docs, I found some backportable clarifications. (Sure, some clarify that the functions are somewhat dangerous with free-threading...)
Also: Turn a mention of
types.ModuleTypeinto a link.📚 Documentation preview 📚: https://cpython-previews--141159.org.readthedocs.build/